package com.infore.statisticsAndAlarm.util;

import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.infore.statisticsAndAlarm.service.ICheckingDatasService;

@Component
public class WaterLevelUtils {
	@Autowired
	ICheckingDatasService iCheckingDatasService;

	//根据水质等级计算水质情况
	public String calculateProject(String waterQuality){
		String calculateQuality = "";
		switch (waterQuality) {
		case "I类":
			calculateQuality = "优";
			break;
		case "II类":
			calculateQuality = "优";
			break;
		case "III类":
			calculateQuality = "良好";
			break;
		case "IV类":
			calculateQuality = "轻度污染";
			break;
		case "V类":
			calculateQuality = "中度污染";
			break;
		case "劣V类":
			calculateQuality = "重度污染";
			break;
		case "I-II类":
			calculateQuality = "优";
			break;
		default:
			calculateQuality = "-";
			break;
		}
		return calculateQuality;
	}
	
	//转换水质类别，将数字换成汉字
	public String exchangeWaterLevelToChinese(String level) {
		Map<String, String> map = iCheckingDatasService.queryTargetLevel();
		String armLevel = "";
		if (StringUtils.isNotBlank(level)  && !"0".equals(level)) {
			armLevel = map.get(level).toString();
		}
		return armLevel;
	}
	
	//转换水质类别，将汉字换成数字
	public String exchangeWaterLevelToNumber(String level) {
		Map<String, String> map = iCheckingDatasService.queryTargetLeveltoNumber();
		String armLevel = "0";
		if (StringUtils.isNotBlank(level)) {
			armLevel = map.get(level) == null ?"0": map.get(level).toString();
		}
		return armLevel;
	}
	
	
}
